//package com.example.ycq.config;
//
//
//import org.apache.commons.dbcp2.ConnectionFactory;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import redis.clients.jedis.JedisPoolConfig;
//
///**
// * 这个类是spring中的redis基础配置
// * 在springboot中不再需要这样配置
// */
////@Configuration
//public class RedisConfig {
//
//    private RedisConnectionFactory connectionFactory=null;
//
//    @Bean(name="RedisConnectionFactory")
//    public RedisConnectionFactory initRedisConnectionFactory(){
//        if(connectionFactory!=null){
//            return this.connectionFactory;
//        }
//
//        JedisPoolConfig poolConfig=new JedisPoolConfig();
//        //最大空闲数
//        poolConfig.setMaxIdle(30);
//        //最大连接数
//        poolConfig.setMaxTotal(50);
//        //最大等待毫秒数
//        poolConfig.setMaxWaitMillis(2000);
//        //创建jedis连接工厂
//        JedisConnectionFactory connectionFactory=new JedisConnectionFactory(poolConfig);
//        //获取单机的redis配置
//        RedisStandaloneConfiguration rsCfg=connectionFactory.getStandaloneConfiguration();
//        connectionFactory.setHostName("192.168.11.131");
//        connectionFactory.setPort(6379);
//        connectionFactory.setPassword("123456");
//        this.connectionFactory=connectionFactory;
//        return connectionFactory;
//    }
//
//    @Bean(name="redisTemplate")
//    public RedisTemplate<Object,Object> initRedisTemplate(){
//        RedisTemplate<Object,Object> redisTemplate=new RedisTemplate<>();
//        redisTemplate.setConnectionFactory(initRedisConnectionFactory());
//        return redisTemplate;
//    }
//}
